Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CxPlatAsync to simplify creating threads with cxplat #49

Merged
merged 10 commits into from
Jul 19, 2024

Conversation

csujedihy
Copy link
Contributor

@csujedihy csujedihy commented Jul 18, 2024

One can easily spin off a thread similar to std::async with this class.

CxPlatAsync Async([](void*) -> void* { /* do something */ return nullptr; });
Async.Wait();

Async.Get(); // get the return value from the callback

Lambda capture could be supported but my C++ skill is not sufficient.

src/test/CxPlatTests.h Outdated Show resolved Hide resolved
inc/cxplat.hpp Outdated Show resolved Hide resolved
inc/cxplat.hpp Outdated Show resolved Hide resolved
csujedihy and others added 3 commits July 19, 2024 10:43
@csujedihy csujedihy force-pushed the huanyi/cpp-helper branch from 6e97c22 to 23a379d Compare July 19, 2024 19:16
@csujedihy
Copy link
Contributor Author

I gave up on implementing thread wait with a timeout. pthread_timedjoin_np doesn't exist in android and mac osx.

@csujedihy csujedihy merged commit 928c497 into main Jul 19, 2024
149 checks passed
@csujedihy csujedihy deleted the huanyi/cpp-helper branch July 19, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants